<script setup lang="ts">
import SimplifyHeader from "@/components/SimplifyHeader.vue";
import { useRouter } from 'vue-router';
import { getSalesBaseInfo } from "@/api/user.js";
import { ref, onMounted } from "vue";
const router = useRouter();

function handleEnterBackend() {
  router.push('/');
}

// 初始化获取用户信息，回填
const info = ref({});
const getInfo = async () => {
  try {
    const res = await getSalesBaseInfo();
    if (res.code === 200) {
      info.value = res.data;
    }
  } catch (e) {
    console.log(e);
  }
};

onMounted(() => {
  getInfo();
});
</script>

<template>
    <div class="create-end">
        <SimplifyHeader :noExit="true"/>
        <div class="content">
            <div class="success-icon">
                <img src="@/assets/create-end-bg.png" alt="成功" class="icon" />
                <img :src="info.avatar" alt="用户头像" class="avatar" />
            </div>
            <div class="user-info">
                <div class="name">恭喜你 <span class="username">{{ info.nickName }}</span></div>
                <div class="rank">入驻成为技能猴子今日第<span class="rank-num">48</span>位卖家！</div>
            </div>
            <div class="description">
                欢迎来到卖家之家，开启圈领超级个体生涯
            </div>
            <div class="action">
                <button class="enter-btn" @click="handleEnterBackend">
                    进入技能猴子卖家后台
                </button>
            </div>
        </div>
    </div>
</template>

<style scoped lang="scss">  
.create-end{
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}
.content{
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    text-align: center;
}
.success-icon {
    margin-bottom: 32px;
    position: relative;
    width: 217px;
    height: 102px;
    display: flex;
    align-items: center;
    justify-content: center;
    .icon {
        width: 217px;
        height: 102px;
        position: absolute;
        top: 0;
        left: 0;
    }
    .avatar {
        width: 58px;
        height: 58px;
        border-radius: 50%;
        object-fit: cover;
        margin-bottom: 16px;
        border: 1px solid #fff;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        margin-top: 40px;
    }
}
.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
    
    .avatar {
        width: 88px;
        height: 88px;
        border-radius: 50%;
        object-fit: cover;
        margin-bottom: 16px;
        border: 3px solid #fff;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    
    .name {
        font-size: 20px;
        font-weight: 600;
        color: #333;
        margin-bottom: 8px;
        
        .username {
            color: #22c55e;
        }
    }
    
    .rank {
        font-size: 18px;
        font-weight: 500;
        color: #333;
        margin-bottom: 16px;
        
        .rank-num {
            color: #22c55e;
            font-weight: 700;
        }
    }
}
.description {
    font-size: 16px;
    color: #666;
    margin-bottom: 48px;
    line-height: 1.5;
}
.action {
    width: 100%;
    max-width: 320px;
    
    .enter-btn {
        width: 100%;
        height: 48px;
        background: #22c55e;
        color: #fff;
        font-size: 16px;
        font-weight: 500;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        
        &:hover {
            background: #16a34a;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
        }
        
        &:active {
            transform: translateY(0);
        }
    }
}
// 响应式设计
@media (max-width: 768px) {
    .user-info {
        .avatar {
            width: 72px;
            height: 72px;
        }
        
        .name {
            font-size: 18px;
        }
        
        .rank {
            font-size: 16px;
        }
    }
    
    .description {
        font-size: 14px;
    }
}
</style>